Unsplash Image Search

The project allows you to search images on Unsplash by using a natural word description. It is powered by OpenAI's CLIP model.

Use this notebook to search for images on Unsplash.

Unsplash API Key

This notebook automatically searches for images on Unsplash and downloads them. For this you will need to have an Unsplash account and to register an application so that you can receive an API key. You can do that here: https://unsplash.com/oauth/applications.

After you have an API key, you need to create a file called .env containing the following text:

UNSPLASH_ACCESS_KEY=<your access key>

Alternatively, just modify the value of the variable unsplash_access_key below.

The search process contains two steps:

  1. Search Unsplash based on some more general keywords and retrieve a large amount of photos.
  2. Evaluate how good each of the photos matches the description using CLIP. The best photos are chosen and displayed.

You need to provide 3 parameters for the search:

Donwload the Photos

We need to retrieve the Unsplash API key so that we can make calls to the API.

We need to first searches Unsplash for photos matching the provided keywords for the initial selection.

After that, we need to download all the selected photos. We download the photos in parallel using 16 threads.

We can now display the photos from the initial selection. They will not yet match you natural language description.

Processing with CLIP

Now we need to process the photos with CLIP. We are basically converting them in a vector space, where they can be compared to a text description. We do the same with the description.

Evaluate similarity

Now we can compare each photo to the text description and choose the most simiar ones